package wec_wallet.ebo.com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import com.bumptech.glide.Glide;

import java.util.ArrayList;
import java.util.List;

import wec_wallet.ebo.com.R;
import wec_wallet.ebo.com.bean.Coin;

/**
 * Created by Administrator on 2018/3/27.
 */

public class SubjectAdapter extends ArrayAdapter<Coin> {
    List<Coin> list = new ArrayList<>();
    private Context mContext;

    public SubjectAdapter(ArrayList<Coin> list, Context context) {
        super(context,android.R.layout.simple_spinner_item, list);
        this.list = list;
        this.mContext = context;
    }
    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
// 修改Spinner下拉字体颜色
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.item_subject, parent, false);
        }
        TextView textView = convertView.findViewById(R.id.item_name);
        ImageView imageView = (ImageView) convertView.findViewById(R.id.item_img);
        textView.setText(list.get(position).getWallet_name());
//        Glide.with(mContext)
//                .load(list.get(position).getIcon())
//                .into(imageView);
        return convertView;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
// 修改Spinner显示字体颜色
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.spinner_display_style2, parent, false);
        }

//注意：text1是系统默认Spinner用来显示文字的TextView控件名称，不可以修改
        TextView txtvwDisplay = (TextView) convertView.findViewById(R.id.txtvwSpinner);
        txtvwDisplay.setText(list.get(position).getWallet_name());
        return convertView;
    }



}
